import java.util.Random;

public class Lab_01 {
    public static void main(String[] args) {
        Random random = new Random();
        System.out.println("50道100以内加减法口算题：");
        System.out.println("========================");
        
        for (int i = 0; i < 50; i++) {
            int a = random.nextInt(101); // 生成0-100的随机数
            int b = random.nextInt(101);
            String operator;
            int result;
            
            if (random.nextBoolean()) {
                // 加法
                operator = "+";
                result = a + b;
                // 如果加法结果超过100，重新生成数字
                while (result > 100) {
                    a = random.nextInt(101);
                    b = random.nextInt(101);
                    result = a + b;
                }
            } else {
                // 减法
                operator = "-";
                // 确保减法结果非负
                if (a < b) {
                    int temp = a;
                    a = b;
                    b = temp;
                }
                result = a - b;
            }
            // 格式化输出，保持对齐
            System.out.printf("%2d: %2d %s %2d = %3d\n", (i+1), a, operator, b, result);
        }
    }
}